<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="oneroom.admin.zipcode.zipcodeModel" %>
<jsp:useBean id="zipcodeDao" scope="page" class="oneroom.admin.zipcode.zipcodeDao" />
<%
	String zip_code4 = request.getParameter("zip_code4") == null ? "" : request.getParameter("zip_code4");
	List list = new ArrayList();
	if(zip_code4 != null && !zip_code4.equals("")){
		list = zipcodeDao.getZipcode(zip_code4);
	}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>주소찾기</title>
<script type="text/javascript" src="/admin/js/default.js"></script>
<link href="/room/css/all.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/js/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
<!--
$(document).ready(function(){
	<%if(list != null && list.size() > 0){%>
	document.getElementById("address_list").style.display="block";
	<%}%>
	$('#zip_ok').click(function() {
		if(document.getElementById("address4").value != "" ){
		opener.document.getElementById("zipcode1").value = document.getElementById("zipcode1").value;
		opener.document.getElementById("zipcode2").value = document.getElementById("zipcode2").value;
		opener.document.getElementById("address1").value = document.getElementById("address1").value;
		opener.document.getElementById("address2").value = document.getElementById("address2").value;
		opener.document.getElementById("address3").value = document.getElementById("address3").value;
		opener.document.getElementById("address4").value = document.getElementById("address4").value;
		//opener.document.getElementById("address5").value = document.getElementById("address5").value;
		window.close();
		}else{
			alert("주소를 정확히 등록 하십시요.");
		}
	});
});
	function getView(zipcode,address1,address2,address3,address4){
		document.getElementById("address_list").style.display="none";
		document.getElementById("address_view").style.display="block";
		document.getElementById("zipcode1").value = zipcode.substring(0,3);
		document.getElementById("zipcode2").value = zipcode.substring(3,6);
		document.getElementById("address1").value = address1;
		document.getElementById("address2").value = address2;
		document.getElementById("address3").value = address3;
		//document.getElementById("address4").value = address4;
		//document.getElementById("address5").value = address5;
	}
//-->
</script>
<style type="text/css">
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
</style>
</head>

<body>
<form action="zipcode.jsp" name="frm" method="post">
<div style="width:420px; border:1px solid #dddddd;">
 <table width="100%" height="30" border="0" cellspacing="0" cellpadding="0">
  <tr>
   <td class="pl10" bgcolor="#3fb1b8"><span style="color:#fff;"><strong>주소검색</strong></span>
		
   </td>
    <td bgcolor="#3fb1b8" width="23"><a href="#" onclick="window.close();"><img src="/room/img/img_x.gif" width="22" height="23" /></a></td>
  </tr>
 </table>
 
  <div class="pt25 pb20" style="text-align:center; line-height:20px;">
	<input type="text" name="zip_code4" style="width:300px;" value="<%=zip_code4 %>"  style="ime-mode:active" > 
	<input type="submit" value="검색" class="btn-black"  />
<br />
</div>
 

  <div id="address_view" style="display: none;">
	 <table width="100%" height="30" border="0" cellspacing="0" cellpadding="0">
	  <tr class="bt2 bb1 h30 bg_g">
	   <td class="fw bb1 pl10" colspan="2">
		<strong>우편 번호 : </strong>
		<input type="text" name="zipcode1" id="zipcode1" style="width:30px;"></input>
		~ <input type="text" name="zipcode2" id="zipcode2" style="width:30px;"></input>
		</td>
	  </tr>
	  <tr class="bt2 bb1 h30 bg_g">
	   <td class="fw bb1 pl10">
		<strong>시/도 : </strong>
		<input type="text" name="address1" id="address1" style="width:50px;"/>
	   </td>
	   <td class="fw bb1" >
	   <strong>구 : </strong>
	   <input type="text" name="address2" id="address2" style="width:100px;"/> 	   
	   </td>
	  </tr>	
	  <tr class="bt2 bb1 h30 bg_g">
	   <td class="fw bb1 pl10">
		<strong>동 : </strong>
		<input type="text" name="address3" id="address3" style="width:100px;"/>
	   </td>
	   <td class="fw bb1 pl10">
	   <strong>번지 : </strong>
	   <input type="text" name="address4" id="address4" style="width:100px;"/> 	   
	   </td>
	  </tr>		    
	  <!-- <tr class="bt2 bb1 h30 bg_g">
	   <td class="fw bb1 pl10" colspan="2">
		<strong>상세 주소 : </strong>
		<input type="text" name="address5" id="address5" style="width:300px;"/>
	   </td>
	  </tr>	   -->
	  <tr class="bt2 bb1 h30 bg_g">
	   <td class="ac bb1" colspan="2">
		<input type="button" name="zip_ok" id="zip_ok" value="확인"/>	 
	   </td>
	  </tr>	  	  
	 </table>  
	</div>

			<div id="address_list" style="display: none;">
			<table width="100%"  border="0" cellspacing="0" cellpadding="0">
			<col width="7%" />
			<col width="10%" />
			<col width="10%" />
			<col width="13%" />
			<col width="10%" />
			<col width="8%" />
			<col width="15%" />
			<col width="12%" />
			<col width="" />
			<%
				if(list != null && list.size() > 0){
				for(int i=0; i<list.size(); i++){
				zipcodeModel model = (zipcodeModel)list.get(i);
			%>		
						
				<tr class="ac fw bt2 bb1 h30 bg_g" style="cursor: hand;"  onclick="javascript:getView('<%=model.getZip_code0()==null ? "" :model.getZip_code0() %>','<%=model.getZip_code2()==null ? "" :model.getZip_code2() %>','<%=model.getZip_code3()==null ? "" :model.getZip_code3() %>','<%=model.getZip_code4()==null ? "" :model.getZip_code4() %>','<%=model.getZip_code5()==null ? "" :model.getZip_code5() %>');">
					<td class="ac bb1"><%=model.getZip_code0()==null ? "" :model.getZip_code0() %>&nbsp;</td>
					<td class="ac bb1"><%=model.getZip_code2()==null ? "" :model.getZip_code2()  %>&nbsp;</td>
					<td class="ac bb1"><%=model.getZip_code3()==null ? "" :model.getZip_code3()  %>&nbsp;</td>
					<td class="ac bb1"><%=model.getZip_code4()==null ? "" :model.getZip_code4()  %>&nbsp;</td>
					<td class="ac bb1"><%=model.getZip_code5()==null ? "" :model.getZip_code5()  %>&nbsp;</td>
					<!-- <td class="ac bb1"><%//=model.getZip_code6()==null ? "" :model.getZip_code6()  %>&nbsp;</td>
					<td class="ac bb1"><%//=model.getZip_code7()==null ? "" :model.getZip_code7()  %>&nbsp;</td>
					<td class="ac bb1"><%//=model.getZip_code8()==null ? "" :model.getZip_code8()  %>&nbsp;</td>
					 -->
				</tr>
			<%
				}
			}
			%>
			</table>			
			</div>
</div>
</form>
</body>
</html>